#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
my $fh;
my $filename = shift;

open ( $fh, '<', $filename);

my $exception="";
my $i=1;
my $avg;
my $min=1000000;
my $max=0;
my %count=();

while (<$fh>) {
	if ( /;yes;/ ) {
		if ( $exception !~ /^\s*$/ ) {
			$exception =~ s/\n/ /g;
			$exception =~ s/;/ /g;
			$exception =~ s/\)/ /g;
			$exception =~ s/\(/ /g;
			$exception =~ s/:/ /g;
			$exception =~ s/=/ /g;
			$exception =~ s/,/ /g;
			$exception =~ s/\./ /g;
			$exception =~ s/\n/ /g;
			$exception =~ s/</ /g;
			$exception =~ s/>/ /g;
			$exception =~ s/\// /g;
			$exception =~ s/\s+/ /g;
			my @tokens=split / /, $exception;
			
			$avg+=scalar @tokens;
			$max=scalar(@tokens) if ($max < scalar(@tokens));
			$min=scalar(@tokens) if ($min > scalar(@tokens));
			
			foreach my $word (@tokens) {
         	               $count{$word}++;
	                }

			print "\n$i)";
			foreach my $k ( keys %count) {
				print "\n\t $k => ".$count{$k};
			}
			$i++;
			%count=();
			#exit 0;
		}
		$exception=$_;
	} else {
		$exception.=$_;
	}

}


close($fh);

$avg=$avg/$i;

print "\nAVG:$avg \nNB:$i \nMIN:$min \nMAX:$max";
